//
//  LBCropConfig.m
//  LBCropImagePage
//
//  Created by mac on 2024/6/2.
//

#import "LBCropConfig.h"

@implementation LBCropConfig

- (instancetype)initWithImgae:(UIImage *)image 
                  cropWHRatio:(CGFloat)cropWHRatio
                  originAngle:(kCropOriginAngle)originAngle
                        angle:(CGFloat)angle
                    zoomScale:(CGFloat)zoomScale
                contentOffset:(CGPoint)contentOffset
{
    if (self = [super init]) {
        self.image = image;
        self.cropWHRatio = cropWHRatio;
        self.originAngle = originAngle;
        self.angle = angle;
        self.zoomScale = zoomScale;
        self.contentOffset = contentOffset;
    }
    return self;
}

- (instancetype)initWithImage:(UIImage *)image
{
    return [self initWithImgae:image
                   cropWHRatio:0
                   originAngle:kCropOriginAngle0
                         angle:0
                     zoomScale:1
                 contentOffset:CGPointZero];
}

#pragma mark - nscoding

- (instancetype)initWithCoder:(NSCoder *)coder
{
    if (self = [super init]) {
        _modified = [coder decodeBoolForKey:@"modified"];
        _imageLocalId = [coder decodeObjectForKey:@"imageLocalId"];
        _cropWHRatio = [coder decodeFloatForKey:@"cropWHRatio"];
        _cropRatioType = [coder decodeIntegerForKey:@"cropRatioType"];
        _originAngle = [coder decodeIntegerForKey:@"originAngle"];
        _angle = [coder decodeFloatForKey:@"angle"];
        _zoomScale = [coder decodeFloatForKey:@"zoomScale"];
        _contentOffset = [coder decodeCGPointForKey:@"contentOffset"];
    }
    return self;
}

- (void)encodeWithCoder:(NSCoder *)coder
{
    [coder encodeBool:self.modified forKey:@"modified"];
    [coder encodeObject:self.imageLocalId forKey:@"imageLocalId"];
    [coder encodeFloat:self.cropWHRatio forKey:@"cropWHRatio"];
    [coder encodeInteger:self.cropRatioType forKey:@"cropRatioType"];
    [coder encodeInteger:self.originAngle forKey:@"originAngle"];
    [coder encodeFloat:self.angle forKey:@"angle"];
    [coder encodeFloat:self.zoomScale forKey:@"zoomScale"];
    [coder encodeCGPoint:self.contentOffset forKey:@"contentOffset"];
}

@end
